package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SyncLog;
import com.ruoyi.system.service.ISyncLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 同步日志管理Controller
 * 
 * @author ruoyi
 */
@RestController
@RequestMapping("/system/datasync/log")
public class SyncLogController extends BaseController
{
    @Autowired
    private ISyncLogService syncLogService;

    /**
     * 查询同步日志列表
     */
    @PreAuthorize("@ss.hasPermi('system:datasync:log:list')")
    @GetMapping("/list")
    public TableDataInfo list(SyncLog syncLog)
    {
        startPage();
        List<SyncLog> list = syncLogService.selectSyncLogList(syncLog);
        return getDataTable(list);
    }

    /**
     * 导出同步日志列表
     */
    @PreAuthorize("@ss.hasPermi('system:datasync:log:export')")
    @Log(title = "同步日志管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SyncLog syncLog)
    {
        List<SyncLog> list = syncLogService.selectSyncLogList(syncLog);
        ExcelUtil<SyncLog> util = new ExcelUtil<SyncLog>(SyncLog.class);
        return util.exportExcel(list, "同步日志数据");
    }

    /**
     * 获取同步日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:datasync:log:query')")
    @GetMapping(value = "/{logId}")
    public AjaxResult getInfo(@PathVariable("logId") Long logId)
    {
        return AjaxResult.success(syncLogService.selectSyncLogById(logId));
    }

    /**
     * 删除同步日志
     */
    @PreAuthorize("@ss.hasPermi('system:datasync:log:remove')")
    @Log(title = "同步日志管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{logIds}")
    public AjaxResult remove(@PathVariable Long[] logIds)
    {
        return toAjax(syncLogService.deleteSyncLogByIds(logIds));
    }
} 